package org.skycastle.megastructure

import com.jme.bounding.BoundingBox
import com.jme.math.{Vector3f, Quaternion}
import com.jme.scene.shape.Box
import com.jme.scene.Node

/**
 *
 *
 * @author Hans Haggstrom
 */

class Character extends Entity( new Figure( 1.8f ) ) {

/*
  val appearance : Appearance = new Ball( 1, "images/sandy_ground.jpg" )
*/
/*
  val appearance : Appearance = new Figure( 1.8f )
*/

  val height = 1.8f
  def getHeight = height



  private val ForwardSpeed = 5f
  private val BackSpeed = 2f
  private val TurnSpeed = 0.4f

  def moveForward( duration : Float ) {
    setRelativeAcceleration( ForwardSpeed, 0, 0 )
  }

  def moveBack( duration : Float ) {
    setRelativeAcceleration( -BackSpeed, 0, 0 )
  }

  def turnLeft( duration : Float ) {
    rotate( duration * TurnSpeed, 0f, 1f, 0f )
  }

  def turnRight( duration : Float ) {
    rotate( duration * -TurnSpeed, 0f, 1f, 0f )
  }

  private val ShotInitialVelocity = new Vector3f( 100f, 5f, 0f)

  def fire( duration : Float ) {

    val shot = new Shot()
    val vel = new Vector3f()
    val pos = new Vector3f()
    val rot = new Quaternion()
    getPosition( pos )
    getRotation( rot )

    shot.setRotation( rot )
    shot.setRelativeVelocity( ShotInitialVelocity )

    space.addEntity( shot, pos )
  }

}